<template>
  <div class="Major" :style="{ 'background-image': 'url(' + detailData.imageUrl + ')' }">
    <div class="layout">
      <div class="top">
        <div class="nav">
          <h1>专业分类</h1>
          <ul>
            <li v-for="item in dataList" :key="item.id" :class="active == item.id ? 'active' : null" @click="changeContent(item.id)">
              <span>{{ item.cnName }}</span>
              <img :src="active === item.id ? activeNavToRight : navToRight" alt="" />
            </li>
          </ul>
        </div>
        <div class="introduction">
          <h1 class="title">{{ detailData.enName }}</h1>
          <div class="des">
            <h1>{{ detailData.cnName }}介绍</h1>
            <p>
              {{ detailData.summary }}
            </p>
          </div>
        </div>
      </div>
      <div class="content">
        <slot v-if="
            detailData && detailData.directions && detailData.directions.length
          ">
          <h1>{{ detailData.cnName }}专业细分</h1>
          <ul class="specialty-segmentation">
            <li v-for="(item, idx) in detailData.directions" :key="idx">
              <h3>{{ item.cnName }}</h3>
              <p>{{ item.enName }}</p>
            </li>
          </ul>
        </slot>

        <h1>课程设置</h1>
        <div class="curriculum-provision">
          <p v-for="(item, index) in detailData.curriculum" :key="index">
            {{ item }}
          </p>
        </div>
        <h1>就业前景</h1>
        <div class="curriculum-provision">
          <p v-for="(item, index) in detailData.employmentProspect" :key="index">
            {{ item }}
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { toRefs, getCurrentInstance, reactive, onMounted } from "vue";
import { useRouter } from "vue-router";
export default {
  name: "Major",
  components: {},
  setup() {
    const { proxy } = getCurrentInstance();
    const router = useRouter();
    let dataObj = reactive({
      dataList: [],
      active: 1,
      detailData: [],
      navToRight: require("./img/nav-to-right.png"),
      activeNavToRight: require("./img/active-nav-to-right.png")
    });

    /**
     * 请求接口
     */
    let getList = () => {
      proxy.$https.get("/api/admin/prod-api/art/major/list").then((res) => {
        if (res.code === 200) {
          dataObj.dataList = res.rows;
          dataObj.active = res.rows[0].id;
          dataObj.detailData = {
            ...res.rows[0],
            curriculum: res.rows[0].curriculum.split(" "),
            employmentProspect: res.rows[0].employmentProspect.split(" ")
          };
        }
      });
    };
    onMounted(() => {
      getList();
    });
    const changeContent = (id) => {
      dataObj.active = id;
      var arr = dataObj.dataList.filter((item) => item.id === id);
      dataObj.detailData = {
        ...arr[0],
        curriculum: arr[0].curriculum.split(" "),
        employmentProspect: arr[0].employmentProspect.split(" ")
      };
    };
    return {
      ...toRefs(dataObj),
      changeContent
    };
  }
};
</script>
<style scoped lang="scss">
@font-face {
  font-family: "font-one";
  src: url("../../../assets/Morganite-Black-2.ttf");
}
.Major {
  width: 100%;

  background: no-repeat left top;
  background-size: 1200px 720px;
  padding-bottom: 180px;
  .layout {
    width: 1200px;
    margin: 0 auto;
    padding-top: 225px;
    .top {
      height: auto;
      display: flex;
      // align-items: flex-end;
      justify-content: space-between;
      .nav {
        width: 330px;
        // height: 550px;
        margin-top: 300px;
        background: rgba(255, 107, 25, 0.8);
        padding: 36px 34px;

        h1 {
          font-family: HarmonyOS_Sans_SC_Black;
          font-size: 40px;
          color: #ffffff;
          line-height: 56px;
          text-align: left;
          font-style: normal;
        }
        ul {
          margin-top: 30px;
          li {
            display: flex;
            align-items: center;
            width: 100%;
            padding: 0 12px;
            margin-bottom: 20px;
            cursor: pointer;
            span {
              font-family: PingFangSC, PingFang SC;
              font-weight: 500;
              font-size: 18px;
              color: #ffffff;
              line-height: 25px;
              text-align: left;
              font-style: normal;
            }
            img {
              width: 16px;
              height: 16px;
              display: block;
              margin-left: 8px;
            }
          }
          .active {
            background: #ffffff;
            height: 45px;
            span {
              font-family: PingFangSC, PingFang SC;
              font-weight: 500;
              font-size: 18px;
              color: rgba(42, 42, 42, 1);
              line-height: 25px;
              text-align: left;
              font-style: normal;
            }
          }
        }
      }
      .introduction {
        width: 766px;
        .title {
          min-height: 480px;
          text-align: right;
          font-family: "font-one";
          font-size: 270px;
          line-height: 240px;
          color: rgba(255, 107, 25, 1);
          display: flex;
          align-items: flex-end;
          justify-content: flex-end;
        }
        .des {
          margin-top: 52px;
          h1 {
            font-family: PingFangSC, PingFang SC;
            font-weight: 600;
            font-size: 28px;
            color: #2a2a2a;
            line-height: 40px;
            text-align: left;
            font-style: normal;
            position: relative;
          }
          h1:before {
            content: "";
            display: block;
            position: absolute;
            left: 0;
            bottom: 0;
            width: 196px;
            height: 12px;
            background: linear-gradient(
              270deg,
              rgba(255, 107, 25, 0) 0%,
              #ff6b19 100%
            );
          }
          p {
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: 16px;
            color: #333333;
            line-height: 32px;
            text-align: justify;
            font-style: normal;
            margin-top: 40px;
          }
        }
      }
    }
    .content {
      width: 100%;
      h1 {
        margin-top: 90px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 28px;
        color: #2a2a2a;
        line-height: 40px;
        text-align: left;
        font-style: normal;
        position: relative;
      }
      h1:before {
        content: "";
        display: block;
        position: absolute;
        left: 0;
        bottom: 0;
        width: 196px;
        height: 12px;
        background: linear-gradient(
          270deg,
          rgba(255, 107, 25, 0) 0%,
          #ff6b19 100%
        );
      }

      .specialty-segmentation {
        width: 100%;
        display: grid;
        // flex-wrap: wrap;
        margin-top: 40px;
        justify-content: space-between;
        grid-template-columns: repeat(auto-fill, 260px);
        grid-gap: 0 1px;
        li {
          width: 260px;
          margin-bottom: 30px;
          display: flex;
          flex-direction: column;
          padding-top: 10px;
          padding-left: 14px;
          background: linear-gradient(
            90deg,
            rgba(159, 159, 158, 0.4) 0%,
            rgba(186, 186, 186, 0.2) 100%
          );
          h3 {
            font-family: PingFangSC, PingFang SC;
            font-weight: 500;
            font-size: 20px;
            color: #333333;
            line-height: 30px;
            text-align: left;
            font-style: normal;
          }
          p {
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: 16px;
            color: #333333;
            line-height: 30px;
            text-align: left;
            font-style: normal;
          }
        }
      }
      .curriculum-provision {
        margin-top: 20px;
        p {
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 16px;
          color: #333333;
          line-height: 30px;
          text-align: left;
          font-style: normal;
        }
      }
    }
  }
}
</style>
